﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace UniversityStudentManagemnetSystem.BLL
{
    public class Manager
    {
        protected enum Rows
        {
            
            oneRowAffected = 1,
            noRowAffected = 0,
            oneRowSelected = 1,
            noRowSeleced = 0,
            oneRowCounted = 1,
            noRowCounted = 0
        }
        private bool IsInteger(string stringValue)
        {
            int number;
            bool boolValue = int.TryParse(stringValue, out number);
            return boolValue;
        }

        private bool IsDouble(string stringValue)
        {
            double number;
            bool value = double.TryParse(stringValue, out number);
            return value;
        }

        protected bool IsValidString(string name)
        {
            bool value = !name.Equals("");
            return value;
        }

        protected bool IsEmail(string name)
        {
            bool value = (name.Contains("@") && name.ToLower().Contains(".com")) &&
                         (name.IndexOf('@') < name.ToLower().IndexOf(".com")) && name.IndexOf('@') != 0;
            return value;
        }

        protected bool IsContactNo(string contactNo)
        {
            int zeroNoIndex = 0;
            int startIndex = 1;
            string plusChar = "+";

            if (contactNo.Contains(plusChar) && contactNo.IndexOf(plusChar) == zeroNoIndex)
            {
                string subString = contactNo.Substring(startIndex, contactNo.Length - 1);
                return IsInteger(subString);
            }
            else
            {
                bool value = IsInteger(contactNo);
                return value;
            }

        }

        protected bool IsCredit(string credit)
        {
            bool value = IsDouble(credit) && Convert.ToDouble(credit) % 0.5 == 0.0;
            return value;
        }
    }
}